/* 
 * Copyright 2009 Shared Object (www.sharedobject.ch)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package edos.prm.metrics;


import edos.prm.event.Event;
import edos.prm.task.Task;

/**
 * A {@code MetricEvent} can be launched by a metric to indicate that a metric
 * has attained a certain measure.
 * 
 * @version 1.0
 *
 */
public interface MetricEvent extends Event {

	/**
	 * Indicates the metric bound to this event
	 * 
	 * @return a Metric object bound to the event
	 */
	public Metric getMetric();
	
	/**
	 * Gives the measure that led to this event being triggered
	 * 
	 * @return the number value that led to this event being triggered.
	 */
	public Number getMeasure();
	
	/**
	 * A default implementation of {@code MetricEvent}.
	 */
	static class PrmMetricEvent implements MetricEvent {

		private Number measure;
		private Metric metric;
		private Task task;
		
		PrmMetricEvent(Number measure, Metric metric, Task task) {
			this.measure = measure;
			this.metric = metric;
			this.task = task;
		}

		public Number getMeasure() {
			return measure;
		}

		public Metric getMetric() {
			return metric;
		}

		public Task getTask() {
			return task;
		}
		
	}
}
